<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title></title>
 <#include "/header.ftl">
</head>
<body>
<div id="app">
    <h1>考试科目</h1>
    <div>
        <el-table  :data="tableData"    style="width: 100%">
            <el-table-column  type="index"  label="序号" width="40">
            </el-table-column>
            <el-table-column  prop="courseId"  label="课程编号">
            </el-table-column>
            <el-table-column  prop="courseName"  label="课程名称"></el-table-column>
            <el-table-column  prop="teacher.teacherRealname"  label="授课教师"></el-table-column>
            <el-table-column  prop="courseCreateDate"  label="添加日期" :formatter='dateFormat'></el-table-column>
            <el-table-column  label="操作">
                <template slot-scope="scope">
                    <el-button type="primary"  size="small" @click.native="getDetial(scope.$index,scope.row)">开始考试</el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="block">
            <el-pagination

                    @current-change="handleCurrentChange"
                    :current-page.sync="pageIndex"
                    :page-size="pageSize"
                    layout="prev, pager, next, jumper"
                    :total="total">
            </el-pagination>
        </div>
        <!-- 弹出框 -->
        <el-dialog title="章节信息" :visible.sync="dialogTableVisible">

            <el-table :data="sectionData"  max-height="250" >
                <el-table-column property="sectionId" label="章节编号" width="150"></el-table-column>
                <el-table-column   label="章节名称" width="200">
                    <template slot-scope="scope">
                        <el-button  type="text" @click.native="getParts(scope.$index,scope.row)"  size="medium ">{{scope.row.sectionName}}</el-button>
                    </template>
                </el-table-column>
                <el-table-column property="sectionAddtime" label="添加时间" :formatter='dateFormat'></el-table-column>
            </el-table>

        </el-dialog>
    </div>
</div>
<#include "/footer.ftl">
<script>

    let _this=new Vue({
        el:'#app',
        data:{
            pageIndex:1,
            pageSize:5,
            total:50,
            tableData: [],
            sectionData:[],
            dialogTableVisible: false,
        },
        created:function () {
            this.getCourseMsg();
        },
        methods: {
            /*日期格式化*/
            dateFormat: function (row, column) {
                let val = row[column.property];
                //console.log(date);
                let date = new Date(val);
                return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
            },
            getParts:function(index,row){
                // location.href=''
            },
            //获取课程的章节信息
            getDetial:function(index,row){
                this.dialogTableVisible = true;

                console.log(row)
                location.href='/sexam?courseId='+row.courseId;
            },

            handleCurrentChange(val) {
                this.pageIndex = val;
                this.getCourseMsg();
            },
            getCourseMsg:function(){
                $.ajax({
                    type:'post',
                    url:'/api/student/listCourse',
                    data:{pageIndex: this.pageIndex},
                    dataType:'json',
                    success:function (res) {
                        console.log(res)
                        _this.pageSize = res.resData.pageSize;
                        _this.total = res.resData.total;
                        _this.tableData = res.resData.list;
                    },
                    error : function(error) {
                        console.log('接口不通' + error);
                    }
                })
            }
        }
    })
</script>
</body>
</html>
